﻿//Js used by CategoryHotPosts widget
//dependence:jquey.core.js

var CategoryHotPosts = function() {
	return {
		init: function(id) {
			var titles = $("#" + id + " dt>a");
			var contents = $("#" + id + " dd");
			var lastindex = titles.length - 1;

			titles.removeClass(
				"on"
			).mouseover(
				function() {
				titles.removeClass("on");
				var currentindex = $.inArray($(this).addClass("on")[0], $.makeArray(titles));
				$("#" + id + " dd:visible").hide();
				contents.eq(currentindex).show();
			}
			).eq(
				lastindex
			).addClass("on");

			//first load.Show the last conent
			contents.hide().eq(lastindex).show();
		}
	}
} ();